using Microsoft.AspNetCore.Mvc;

namespace OrderService.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class OrderController : ControllerBase
    {
        private static   List<string> orders = new List<string>
        {
         "1", "2", "3", "4", "5", "6", "7",  
        };

        private readonly ILogger<WeatherForecastController> _logger;
        private readonly IConfiguration _configuration;

        public OrderController(ILogger<WeatherForecastController> logger,IConfiguration cfg)
        {
            _logger = logger;
            _configuration= cfg;
        }

        [HttpGet(template:nameof(GetAll))]
        public IActionResult GetAll()
        {
            Console.WriteLine($"{DateTime.Now} invoked current Port:"+_configuration["port"]);
            return Ok(orders);
        }

        [HttpPost(nameof(Create))]
        public IActionResult Create([FromBody]string id)
        {
            orders.Add(id);
            return Ok(id);
        }
    }
}